package cn.edu.lit.jsjxy.CourseExample.chapter3;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import cn.edu.lit.jsjxy.CourseExample.R;

public class LifeCycleTestActivity extends Activity implements View.OnClickListener
{
    String TAG = "LifeCycleTestActivity";
    Button btnShowDialog;
    Button btnShowActivity;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_life_cycle_test);

        btnShowDialog = findViewById(R.id.btnshowDialog);
        btnShowDialog.setOnClickListener(this);

        btnShowActivity= findViewById(R.id.btnshowNewActivity);
        btnShowActivity.setOnClickListener(this);


        Log.i(TAG, TAG + "::onCreate");

    }

    @Override
    protected void onStart()
    {
        super.onStart();
        Log.i(TAG, TAG + "::onStart");
    }

    @Override
    protected void onResume()
    {
        super.onResume();
        Log.i(TAG, TAG + "::onResume");
    }

    @Override
    protected void onPause()
    {
        super.onPause();
        Log.i(TAG, TAG + "::onPause");
    }

    @Override
    protected void onStop()
    {
        super.onStop();
        Log.i(TAG, TAG + "::onStop");
    }

    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        Log.i(TAG, TAG + "::onDestroy");
    }

    @Override
    protected void onRestart()
    {
        super.onRestart();
        Log.i(TAG, TAG + "::onRestart");
    }

    public  void showDialog()
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("dialog");
        builder.setMessage("test");
        builder.create().show();
    }

    public void showNewActivity()
    {
        Intent intent = new Intent(this, MenuTestActivity.class);
        startActivity(intent);
    }

    @Override
    public void onClick(View view)
    {
        switch (view.getId())
        {
            case R.id.btnshowDialog:
                showDialog();
                break;

            case R.id.btnshowNewActivity:
                showNewActivity();
                break;
        }

    }
}
